#!/usr/bin/awk -f
BEGIN {
   start_time=0;
   end_time=0;
   num_transactions=0;
   total_time=0;
   
   FS=","
}
/^[0-9]+,[0-9]+,[0-9]+,[0-9]+$/ {
if (num_transactions == 0) start_time=$1+$2/1000;

  t_start = $1 + ($2/1000);
  t_end = $3 + ($4/1000);
  total_time += (t_end-t_start);

  num_transactions++;
}

END {
  end_time = $3+$4/1000;
#print "start time:" start_time
#print "end time:" end_time
#print "total transactions:" num_transactions;
#print "avg trans time:" total_time/num_transactions;
#print "avg trans/sec     :" (num_transactions)/(end_time-start_time);
  printf("%f,%f,%f,%f,%f\n", start_time, end_time, num_transactions, (total_time/num_transactions), (num_transactions/(end_time-start_time)));
}
